From 105ffc8cfa4d8efd51bb7654bfdd279df2a64779 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 3 Sep 2024 12:19:44 +0700
Subject: <iman> update tempt

---
 src/pages/shop/promo/[slug].jsx | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

(limited to 'src/pages/shop/promo/[slug].jsx')

diff --git a/src/pages/shop/promo/[slug].jsx b/src/pages/shop/promo/[slug].jsx
index 71ce8344..169ea0b5 100644
--- a/src/pages/shop/promo/[slug].jsx
+++ b/src/pages/shop/promo/[slug].jsx
@@ -38,14 +38,14 @@ export default function PromoDetail() {
   const [loading, setLoading] = useState(true);
   const { isMobile, isDesktop } = useDevice()
   // const [brands, setBrands] = useState([]);
-  const [categories, setCategories] = useState([]);
+  // const [categories, setCategories] = useState([]);
   const [brandValues, setBrandValues] = useState([]);
   const [categoryValues, setCategoryValues] = useState([]);
   const [orderBy, setOrderBy] = useState(router.query?.orderBy);
   const popup = useActive();
   const prefixUrl = `/shop/promo/${slug}`
   const [queryFinal, setQueryFinal] = useState({});
-  const [limit, setLimit] = useState(30);
+  const [limit, setLimit] = useState(22);
   const [q, setQ] = useState('*');
   const [finalQuery, setFinalQuery] = useState({fq: `type_value_s:${slug}`});
   const [products, setProducts] = useState(null);
@@ -78,18 +78,35 @@ export default function PromoDetail() {
   const brands = [];
   for (
     let i = 0;
-    i < productSearch.data?.facetCounts?.facetFields?.manufactureNameS.length;
+    i < productSearch.data?.facet_counts?.facet_fields?.manufacture_name_s.length;
     i += 2
   ) {
     const brand =
-      productSearch.data?.facetCounts?.facetFields?.manufactureNameS[i];
+      productSearch.data?.facet_counts?.facet_fields?.manufacture_name_s[i];
     const qty =
-      productSearch.data?.facetCounts?.facetFields?.manufactureNameS[i + 1];
+      productSearch.data?.facet_counts?.facet_fields?.manufacture_name_s[i + 1];
     if (qty > 0) {
       brands.push({ brand, qty });
     }
   }
 
+  console.log("brands",brands)
+
+  const categories = [];
+  for (
+    let i = 0;
+    i < productSearch.data?.facet_counts?.facet_fields?.category_name.length;
+    i += 2
+  ) {
+    const name = productSearch.data?.facet_counts?.facet_fields?.category_name[i];
+    const qty =
+      productSearch.data?.facet_counts?.facet_fields?.category_name[i + 1];
+    if (qty > 0) {
+      categories.push({ name, qty });
+    }
+  }
+  
+
 
 
 
-- 
cgit v1.2.3

